// import { USER_INFO } from '@/constants/common';

// 表单类型
export const TYPE = {
  TEXT: 'text',
  DATE: 'date',
  DATETIME: 'datetime',
  PICKER: 'picker',
  ADDRESS: 'address',
  PANEL_MULTIPLE: 'panel_multiple'
};

// 患者字段
const infoField = {
  name: {
    // 姓名
    isShow: 'patientFormNameShow',
    isRequire: 'patientFormNameWrite'
  },
  address: {
    // 地址
    isShow: 'patientFormAddressShow',
    isRequire: 'patientFormAddressWrite'
  },
  birthday: {
    // 出生日期
    isShow: 'patientFormBirthdayShow',
    isRequire: 'patientFormBirthdayWrite'
  },
  educationLevel: {
    // 教育水平
    isShow: 'patientFormEducationLevelShow',
    isRequire: 'patientFormEducationLevelWrite'
  },

  height: {
    // 身高
    isShow: 'patientFormHeightShow',
    isRequire: 'patientFormHeightWrite'
  },

  mobile: {
    // 手机号
    isShow: 'patientFormMobileShow',
    isRequire: 'patientFormMobileWrite'
  },

  sex: {
    // 性别
    isShow: 'patientFormSexShow',
    isRequire: 'patientFormSexWrite'
  },

  profession: {
    // 职业
    isShow: 'patientFormProfessionShow',
    isRequire: 'patientFormProfessionWrite'
  },

  patientFormRelationWithPatient: {
    // 与患者关系
    isShow: 'patientFormRelationWithPatientShow',
    isRequire: 'patientFormRelationWithPatientWrite'
  },

  patientFormOutpatientTime: {
    // 门诊时间
    isShow: 'patientFormOutpatientTimeShow',
    isRequire: 'patientFormOutpatientTimeWrite'
  },

  patientFormOperationTime: {
    // 手术时间
    isShow: 'patientFormOperationTimeShow',
    isRequire: 'patientFormOperationTimeWrite'
  },

  patientFormExamineTime: {
    // 检查时间
    isShow: 'patientFormExamineTimeShow',
    isRequire: 'patientFormExamineTimeWrite'
  },

  patientFormPregnancyWeight: {
    // 孕前体重
    isShow: 'patientFormPregnancyWeightShow',
    isRequire: 'patientFormPregnancyWeightWrite'
  },

  patientFormLastMenstruation: {
    // 末次月经
    isShow: 'patientFormLastMenstruationShow',
    isRequire: 'patientFormLastMenstruationWrite'
  },

  patientFormDueTime: {
    // 预产期
    isShow: 'patientFormDueTimeShow',
    isRequire: 'patientFormDueTimeWrite'
  },

  patientFormMedicalNum: {
    // 住院号
    isShow: 'patientFormMedicalNumShow',
    isRequire: 'patientFormMedicalNumWrite'
  },
  marks: {
    // 标记组
    isShow: 'patientFormMarkShow',
    isRequire: 'patientFormMarkWrite'
  }
};

export const USER_INFO_DATA = [
  {
    field: 'name',
    label: '患者姓名',
    value: '',
    type: TYPE.TEXT,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'sex',
    label: '性别',
    value: '',
    type: TYPE.PICKER,
    isShow: true,
    isRequire: false,
    options: [
      {
        text: '男'
      },
      {
        text: '女'
      }
    ]
  },
  {
    field: 'address',
    label: '地区',
    value: '',
    type: TYPE.ADDRESS,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'profession',
    label: '职业',
    value: '',
    type: TYPE.TEXT,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'birthday',
    label: '出生日期',
    value: '',
    type: TYPE.DATE,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'height',
    label: '身高(cm)',
    value: '',
    type: TYPE.TEXT,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'mobile',
    label: '手机号码',
    value: '',
    type: TYPE.TEXT,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'educationLevel',
    label: '受教育水平',
    value: '',
    type: TYPE.PICKER,
    isShow: true,
    isRequire: false,
    options: [
      {
        text: '小学及以下',
        id: '1'
      },
      {
        text: '初中',
        id: '2'
      },
      {
        text: '高中或中专',
        id: '3'
      },
      {
        text: '大专',
        id: '4'
      },
      {
        text: '本科及以上',
        id: '5'
      }
    ]
  }
];

export const VISIT_INFO_DATA = [
  // 患者就诊信息
  {
    field: 'patientFormRelationWithPatient',
    label: '与患者关系',
    value: '',
    type: TYPE.PICKER,
    isShow: true,
    isRequire: false,
    options: [
      {
        text: '其他家属',
        id: '0'
      },
      {
        text: '本人',
        id: '1'
      },
      {
        text: '父母',
        id: '2'
      },
      {
        text: '子女',
        id: '3'
      }
    ]
  },
  {
    field: 'marks',
    label: '标记组',
    value: '',
    type: TYPE.PANEL_MULTIPLE,
    isShow: false,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormMedicalNum',
    label: '住院号',
    value: '',
    type: TYPE.TEXT,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormOutpatientTime',
    label: '就诊时间',
    value: '',
    type: TYPE.DATE,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormOperationTime',
    label: '手术时间',
    value: '',
    type: TYPE.DATETIME,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormExamineTime',
    label: '检查时间',
    value: '',
    type: TYPE.DATETIME,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormPregnancyWeight',
    label: '孕前体重(kg)',
    value: '',
    type: TYPE.TEXT,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormLastMenstruation',
    label: '末次月经',
    value: '',
    type: TYPE.DATE,
    isShow: true,
    isRequire: false,
    options: []
  },
  {
    field: 'patientFormDueTime',
    label: '预产期',
    value: '',
    type: TYPE.DATE,
    isShow: true,
    isRequire: false,
    options: []
  }
];

export const filterData = (data) => {
  let infoConfigs = JSON.parse(JSON.stringify([...USER_INFO_DATA, ...VISIT_INFO_DATA]));
  return infoConfigs
    .map((item) => {
      item.isShow = data[infoField[item.field].isShow];
      item.isRequire = data[infoField[item.field].isRequire];
      return item;
    })
    .filter((item) => !!item.isShow);
};
